package com.ibm.cloud.envcheck.basicservice;

import java.io.File;

import com.ibm.cloud.envcheck.bean.RemoteParam;
import com.ibm.cloud.envcheck.kit.FileUtils;
import com.ibm.cloud.envcheck.service.RemoteBasicService;
import com.ibm.cloud.envcheck.service.type.ServiceType;

public class RemoteExeCommandLineService extends RemoteBasicService<RemoteParam> {
	
	public static void main(String []args){
		RemoteParam cp = new RemoteParam();
		cp.setCommand("ls");
		cp.setHost("9.111.139.142");
		cp.setPort(22);
		cp.setUsername("root");
		cp.setPassword("macky123");
		
		RemoteExeCommandLineService recl = new RemoteExeCommandLineService();
		
		recl.handle(cp);
		//recl.printResult(recl.getIn());
		
		File file = new File("/Users/macky/Desktop/hello.txt");
		FileUtils.WriteFileFromInputStream(recl.getIn(), file);
	}

	@Override
	public void handle(RemoteParam t) {
		initChannel(t);
		//printResult(getIn());
		destroy();
	}

	@Override
	public int getCode() {
		return 1;
	}
	
	

}
